import { reactive } from "vue";
import { defineStore } from 'pinia';

export const useFlowStore = defineStore('flow', {
    state: () => ({
        flowModel: reactive({
            id: '',
            flowName: '',
            flowTypeId: '',
            flowTypeName:'',
            isUsed: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: ''
        }),
        flowNodeModel: reactive({
            id: '',
            fid: '',
            nodeName: '',
            approveUserId: '',
            approveUserName: '',
            approveRoleId: '',
            approveRoleName: '',
            approveType: null,
            passCondition: null,
            prevNodeId: '',
            prevNodeName: '',
            sort: null,
            isUsed: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            flowNodeApproveUsers:[]
        }),
        flowTypeModel: reactive({
            id: '',
            pid: '',
            typeName: '',
            pName:'',
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: ''
        })
    }),
    actions: {
        resetFlowModel() {
            this.flowModel = {
                id: '',
                flowName: '',
                flowTypeId: '',
                flowTypeName:'',
                isUsed: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: ''
            };
        },
        resetFlowNodeModel() {
            this.flowNodeModel = {
                id: '',
                fid: '',
                nodeName: '',
                approveUserId: '',
                approveUserName: '',
                approveRoleId: '',
                approveRoleName: '',
                approveType: null,
                passCondition: null,
                prevNodeId: '',
                prevNodeName: '',
                sort: null,
                isUsed: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                flowNodeApproveUsers:[]
            };
        },
        resetFlowTypeModel() {
            this.flowTypeModel = {
                id: '',
                pid: '',
                typeName: '',
                pName:'',
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: ''
            }
        }
    },
});